from bs4 import BeautifulSoup
import requests


headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36',
    }
base_url = 'https://www.mntup.com'
def download(url):
    out = requests.get(url, headers=headers)
    out.encoding = 'gbk'
    soup = BeautifulSoup(out.text, 'lxml')
    imgs = soup.find(class_='img').find_all('img')
    try:
        for img in imgs:
            url = base_url+img.get('src')
            print(url)
            imge = requests.get(url)
            f = open('one.jpg','ab')
            f.write(imge.content)
            f.close()
    except Exception as e:
        print(e)

if __name__ == '__main__':
    str = 'https://www.mntup.com/XiuRen/baitian_e71fda1d_11.html'
    download(str)